﻿@model IEnumerable<MobileWebsiteGenerator.Entities.pictureGallery>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout_login.he-IL.cshtml";
}
<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
<script type="text/javascript">

    function deleteRecord(recordId) {
        // Perform delete
        var answer = confirm("Are you sure want to delete this picture?");

        if (answer) {
            var action = "/PictureGallery/Delete/" + recordId;

            var request = new Sys.Net.WebRequest();
            request.set_httpVerb("DELETE");
            request.set_url(action);
            request.add_completed(deleteCompleted);
            request.invoke();
        }
    }

    function deleteCompleted() {
        // Reload page
        window.location.reload();
    }</script>
<div style="float: right; width: 680px; vertical-align: top; margin: 0px; padding: 0px;">
    <h3>
        התמונות שלי</h3>

    <p>
      @* <a  href="@Url.Action("Create", "Website", @MobileWebsiteGenerator.MvcApplication._MainCustomer)"   style="float:left;"  id="GoToMain" title="Go to Main page">
                          <img src="../../images/Arrow Left.png"></a>*@
      <a href="@Url.Action("Create", "Picturegallery")" style="padding:5px;background:brown;">
                הוסף עוד<img src="@Url.Content("~/images/add.gif")" style="margin-top:5px;" />
            </a>
    </p>
    @foreach (var item in Model)
    {
        <table style="float: left; margin: 10px;">
            <tr>
                <td style="width: 150px; height: 100px; border: 2px solid #999; border-radius: 4px;">
                    @if (File.Exists(Server.MapPath(Url.Content("~/Uploads/" + item.ImagePath))))
                    {
                      
                         <a href="@Url.Action("Edit", "PictureGallery", new { id = item.picture_id })">   <img src="@Url.Content("~/uploads/" + item.ImagePath)" width="130px" />
                        <strong style="color:Red;">@item.Caption </strong> </a>
                    }
                    else
                    {
                        
                       <a href="@Url.Action("Edit", "PictureGallery", new { id = item.picture_id })">  <img src="@Url.Content("~/uploads/home-icons.png")" width="130px" />
                           <strong>No Caption </strong> </a>
                    }
                </td>
            </tr>
            <tr>
                <td>
                    <a onclick="deleteRecord(@item.picture_id)" href="JavaScript:void(0)" style="margin-top:-20px;float:right;">
                        <img src="@Url.Content("~/images/cancel.png")" style="border:0px;" />
                    </a>
                </td>
            </tr>
        </table>
    }
    <div>
        <a href="@Url.Action("Create", "Website")" class="form_submit" style="padding:10px;background-color:Gray;width:150px;height:60px;color:White;">
            נעשה! </a>
    </div>
</div>
@section MobilePreview
{
    @Html.Partial("_PreviewOnMobile.he-IL", MobileWebsiteGenerator.MvcApplication._MainCustomer);
}
